<?php
declare (strict_types = 1);

namespace app\common\model;

use think\Model;
use think\model\concern\SoftDelete;
class ZadanConfig extends Model
{
    use SoftDelete;
     protected $deleteTime = "delete_time";
    // 获取列表
    public static function getList()
    {
        $where = [];
        $limit = input('get.limit');
        
               //按活动是否开启(1.开启  0.关闭)查找
               if ($activiteisopen = input("activiteisopen")) {
                   $where[] = ["activiteisopen", "like", "%" . $activiteisopen . "%"];
               }
               //按玩法介绍内容查找
               if ($desc = input("desc")) {
                   $where[] = ["desc", "like", "%" . $desc . "%"];
               }
               //按开启连抽类型列表查找
               if ($typels = input("typels")) {
                   $where[] = ["typels", "like", "%" . $typels . "%"];
               }
               //按兑换比例查找
               if ($dhbl = input("dhbl")) {
                   $where[] = ["dhbl", "like", "%" . $dhbl . "%"];
               }
               //按日榜单发放物品查找
               if ($daysendgoodsls = input("daysendgoodsls")) {
                   $where[] = ["daysendgoodsls", "like", "%" . $daysendgoodsls . "%"];
               }
               //按总榜单发放物品查找
               if ($allsendgoodsls = input("allsendgoodsls")) {
                   $where[] = ["allsendgoodsls", "like", "%" . $allsendgoodsls . "%"];
               }
               //按主播在后台发放数量限制查找
               if ($sendcoinlimit = input("sendcoinlimit")) {
                   $where[] = ["sendcoinlimit", "like", "%" . $sendcoinlimit . "%"];
               }
               //按多少金币开启一次查找
               if ($onenumcoin = input("onenumcoin")) {
                   $where[] = ["onenumcoin", "like", "%" . $onenumcoin . "%"];
               }
               //按单日排名发送名次数查找
               if ($rankdaynum = input("rankdaynum")) {
                   $where[] = ["rankdaynum", "like", "%" . $rankdaynum . "%"];
               }
               //按所有排名发送名称数查找
               if ($rankallnum = input("rankallnum")) {
                   $where[] = ["rankallnum", "like", "%" . $rankallnum . "%"];
               }
               //按创建时间查找
               $start = input("get.create_time-start");
               $end = input("get.create_time-end");
               if ($start && $end) {
                   $where[]=["create_time","between",[$start,date("Y-m-d",strtotime("$end +1 day"))]];
               }
        $list = self::order('id','desc')->where($where)->paginate($limit);
        return ['code'=>0,'data'=>$list->items(),'extend'=>['count' => $list->total(), 'limit' => $limit]];
    }
}
